package cn.tedu.stock.mapper;

import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

@Mapper
public interface StockMapper {
    //自定义一个扩展的方法
    @Update("update stock_tbl set stock = stock - #{count} where product_code = #{productCode} and stock>#{count}")
    Integer reduceStock(String productCode,Integer count);

    //查询库存
    @Select("select stock from stock_tbl where product_code = #{productCode}")
    Integer checkStock(String productCode);
}
